import React, {Component} from 'react';
import {
    View,
    Text,
    TouchableOpacity,
} from 'react-native';

import {syscenterStyle as styles} from '../../../../styles';

let Dimensions = require('Dimensions');
let width = Dimensions.get('window').width;

export default class Sysresumestate extends Component {

    constructor(props) {
        super(props);
        this.state = {
            isVisible: this.props.resume.resumeYm,
        }
    };

    render() {
        return (
            <View style={[styles.center2, {width: width * 1}]}>
                <View>
                    <Text style={styles.text5}>你的简历处于{this.state.isVisible === 0 ? '开放状态' : '隐藏状态'}</Text>
                    <Text style={styles.text5}>
                        {this.state.isVisible === 0 ? '不想公开简历可以选择隐藏' : '开放简历让企业HR可以看见你'}
                    </Text>
                </View>

                <View>
                    <TouchableOpacity
                        activeOpacity={1}
                        style={styles.button1}
                        onPress={() => this.change()}
                    >
                        <Text style={styles.button2}>
                            {this.state.isVisible === 0 ? '立即隐藏' : '立即开放'}

                        </Text>
                    </TouchableOpacity>
                </View>
            </View>
        )
    }

    change() {
        if (this.state.isVisible === this.props.resume.resumeYm) {
            let newState = 0;
            if (this.state.isVisible === 0) {
                newState = 1;
            }
            const resume = {
                resumeId: this.props.resume.resumeId,
                memberId: this.props.resume.memberId,
                resumeYm: newState,
            };
            this.props.actions.UpdateResumeAction(resume);
            this.setState({isVisible: newState});
        }
    }

}

